package com.lww.feature.test.exceptiontest;

import javax.sound.midi.Soundbank;
import java.io.IOError;

/**
 * User: yian
 * Date: 2017/11/19
 */
public class test {
    public static void main(String[]args) {
        //int a = new ReferenceTypeTest().absorbeTheValue();
        //int a = foo();
//         foo2();
//        System.out.println(a);
        System.out.println(ddd());
    }

    static String ddd(){
        return ccc();
    }
    static String ccc(){
        try {
           return bbb();
        }catch (Exception e){
            throw new RuntimeException("哈哈哈",e);
        }
    }

    static String bbb(){
        return aaa();
    }

    static String aaa(){
        return sssss();
    }

    static String sssss() {
        String output = "";
        try {


            try {
                throw new IllegalArgumentException("1");
            } catch (Exception e) {
                RuntimeException runtimeException = new RuntimeException();
                runtimeException.initCause(e);
                throw runtimeException;
            }
        } catch (Exception e) {
            RuntimeException runtimeException = new RuntimeException();
            runtimeException.initCause(e);
            throw runtimeException;
        }


    }



    int absorbeTheValue() {
        try {
            int a = 10/0;
            return a;
        } catch(Exception e) {
            int c = 1/0;
            return 45;
        }
        finally {
            System.out.println("=====");
            int b = 1/0;
        }
    }
    private static int foo() {
        try {
            int n = Integer.parseInt("3pp");
            return n;
        }
        finally {
            return 42;
        }
    }
    private static void foo2() {
        try {
            int n = Integer.parseInt("3e");
        }
        finally {
            System.out.println("3");
        }
    }

    private static int foo3() {
        try {
            int n = Integer.parseInt("3");
            return n;
        }
        finally {
//            System.out.println("3");
            int b = 1/0;
            return 5;
        }
    }
}
